package dao;

import helper.CleanHelper;

import java.sql.SQLException;
import java.util.Vector;

import com.mysql.jdbc.ResultSet;

public class WordListDao {
	private ConnectionDB c;
	
	public WordListDao()
	{
		this.c = new ConnectionDB();
	}
	
	public void insert(String word, String paras)
	{
		c.ajouter("Insert into wordList(word, containerPara) values ('"+ word + "' , '" + paras + "' )");
	}
	
	public Vector<Vector<String>> getAll()
	{
		Vector<Vector<String>> result = new Vector<Vector<String>>();
		
		ResultSet rs = c.rechercher("Select * from wordList;");
		
		try {
			while(rs.next())
			{
				Vector<String> v = new Vector<String>();
				v.add(CleanHelper.formatLabel(rs.getString(2)));
				v.add(rs.getString(3));
				result.add(v);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}
	
	public void close()
	{
		c.fermer();
	}
}
